home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_lockeddoor.cog < prev    next >
Text File  |  1999-11-15  |  3KB  |  135 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_LockedDoor.cog
  4. #
  5. # Indy notes locked doors whose keyhole is elsewhere
  6. #
  7. # [HB]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ==============================================================================
  11.  
  12. # NOTE: This is a random verbal door reaction cog.  Glue it into your level and
  13. # reach it from a calling cog like this:
  14. #
  15. # 1. Create a valid reference to this cog in your calling cog;
  16. #
  17. # 2. Use the following verb:
  18. #    SendMessageEx(thiscogREF, i_userMessage, f_parm0, f_parm1, f_parm2, f_parm3);
  19. #    (see each section below for details...)
  20. #
  21. # 3. Use global15 as a semaphore and return value where neeeded;
  22. #
  23. # The resulting chatter is pre-approved by HB...
  24. #
  25. # PRODUCT SUPPORT:  cogsrus x8371
  26.  
  27. # ==============================================================================
  28.  
  29. symbols
  30.  
  31. # ................................. MESSAGES ...................................
  32.  
  33.     message user0
  34.  
  35. # ................................. SAY LINES ..................................
  36.  
  37.     # door locked lines...
  38.     sound    in_sayline=Inxj076.wav                local # This...locked-->in_sayline[0]
  39.     sound    in_islocked=Inxj077.wav                local # It's locked.
  40.     sound    in_locked=Inxj078.wav                local # Locked.
  41.     sound    in_lockedagain=Inxj079.wav            local # Locked again.
  42.     sound    in_lockedluck=Inxj080.wav            local # Locked...luck never changes.
  43.     sound    in_whyalwayslocked=Inxj081.wav        local # Oh no...why...always locked?
  44.  
  45. # ............................... VARIABLES ....................................
  46.  
  47.     flex    talkerREF                            local
  48.     flex    forceTalk                            local
  49.     flex    forceLine                            local
  50.  
  51.     int        alreadyworking=0                    local
  52.  
  53.     int        newline=50                            local # init outside actual range
  54.     int        oldline=50                            local
  55.  
  56.     int        dummy
  57.         
  58. end
  59.  
  60. # ==============================================================================
  61.  
  62. code
  63.  
  64. # ..............................................................................
  65.  
  66. user0:
  67.  
  68.     # Indy reacts verbally to a locked door player has ACTIVATED...
  69.     #
  70.     # Proper command to reach this response section from the calling cog is:
  71.     #
  72.     # SendMessageEx(lockdoorcogREF, user0, f_talkerREF, f_rightItem, f_triedItem, 0);
  73.     #
  74.     # global15 is used by this cog and the calling cog, like so:
  75.     #
  76.     # global15 == 0 while this cog is at work (waiting for line to finish)
  77.     # global15 == 1 upon return
  78.     #
  79.     # The calling cog can use the 0 value as a semaphore to pause execution, thus:
  80.     #
  81.     # global15 = 0; # init just in case in your own cog!
  82.     # while (global15 == 0)
  83.     # {
  84.     #    # Wait for line to finish...
  85.     #    Sleep(0.01);
  86.     # }
  87.  
  88.     if (alreadyworking != 0)
  89.     {
  90.         return;
  91.     }
  92.  
  93.     global15 = 0; # init each call
  94.  
  95.     talkerREF = GetParam(0); # is player or an actor talking? (a cast)
  96.     forceTalk = GetParam(1); # force a choice
  97.     forceLine = GetParam(2); # actual line choice
  98.     
  99.     alreadyworking = 1; # stall multiple calls
  100.  
  101.     if (forceTalk != 0)
  102.     {
  103.         newline = forceLine; # choose this line
  104.         oldline = 0;
  105.     }
  106.  
  107.     while (newline == oldline)
  108.     {        
  109.         newline = RandBetween(0, 19);
  110.         if (newline < 16)
  111.         {    
  112.             newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  113.         }
  114.         if (newline > 17)
  115.         {
  116.             newline = (newline - 14); # 1/20 chance for 4 or 5 
  117.         }    
  118.         if (newline > 15)
  119.         {
  120.             newline = 3; # 1/10 chance for 3
  121.         }
  122.     }
  123.     oldline = newline;
  124.  
  125.     PlayVoice(talkerREF, in_sayline[newline], 1, 1);
  126.  
  127.     global15 = 1;
  128.     alreadyworking = 0;
  129.  
  130.     return;
  131.  
  132. end
  133.  
  134.  
  135.